<?php for ($i = 1; $i <= 5; $i++): ?>
    <!-- this in it's own is the beginning of a great career of the Giant -->
    <div class="rate-doctor <?php
    if ($i <= $doctorAverageRating)
    {
        echo "full-star";
    }
    else
    {
        echo ((($i - $doctorAverageRating) > 0 && ($i - $doctorAverageRating) < 1) && $doctorAverageRating > 0) ? "half-star" : "empty-star";
    }
    ?>" rating="<?php echo $i; ?>"></div>
<?php endfor; ?>
<script type="text/javascript">
    $(document).ready(function(){    
        $("#doctor-rating-<?php echo $doctor->getId() ?> .rate-doctor").click(function(){
            $("#doctor-rating-<?php echo $doctor->getId() ?>").load("/doctor-rate/<?php echo $doctor->getId() ?>" + "/" + $(this).attr("rating"));
            
            if($("#average-rating-panel").val() != undefined){
                $("#average-rating-panel").load("/doctor-rating-average/<?php echo $doctor->getId() ?>");                
            }
        });
    });
</script>